
.text
	.align 4
	.global begin
	.type begin, function

begin:
    b reset_handler
    b undefied_handler
    b swi_handler
    b prefetch_handler
    b abort_handler
    nop
    b irq_handler
    b fiq_handler

/* all begins here */
reset_handler:
    /* into user mode first */
    mrs r0, cpsr
    bic r0, r0, #0x0f        @ clear last four bits to 0
    orr r0, r0, #0x10        @ set the last fifth bit to 1
    msr cpsr_c, r0

    /* into svc mode by generating SWI exception */
    svc 0x123456

undefied_handler:
    b undefied_handler
prefetch_handler:
    b prefetch_handler
abort_handler:
    b abort_handler
irq_handler:
    b irq_handler
fiq_handler:
    b fiq_handler
swi_handler:
    ldr r0, [lr, #-4]
    bic r0, r0, #0xff000000     @ get the immediate-24
    b stop

stop:
    b stop
